package alarm;

public class AlarmSystem {

	/**
	 * @param args
	 */
	static AlarmFactory af;
	static final String[] filterDescriptions = { "shop", "chief", "stam" };
	static final boolean[] withStatistics = { true, true, false };

	static public AbstractFilter[] createSystem(String[] filterDescriptions,
			boolean[] withStatistics) {
		AbstractFilter[] absF = new AbstractFilter[filterDescriptions.length];
		for (int i = 0; i < filterDescriptions.length; i++)
			absF[i] = new DecoratedFilter(filterDescriptions[i],
					withStatistics[i]);
		return absF;
	}

	public static void main(String[] args) {
		af = new AlarmFactory();
		AbstractFilter[] filters = createSystem(filterDescriptions,
				withStatistics);
		Detector[] detectors = new Detector[filters.length];
		for (int i = 0; i < detectors.length; i++) {
			detectors[i] = af.createDetector();
			detectors[i].setObserver(filters[i]);
			filters[i].setObserver(af.getAlarm());
		}
		for (int i = 0; i < detectors.length; i++) 
			detectors[i].alarm("chief detector #" + Integer.toString(i) );
	}

}
